package com.apes.fico.engine.repository;

import com.apes.fico.engine.model.BusinessDocument;
import com.apes.fico.engine.model.VoucherTemplate;
import com.apes.framework.jpa.repository.CustomRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface BusinessDocumentRepository extends CustomRepository<BusinessDocument, String> {

    void deleteByBusinessTypeAndBusinessIdAndVoucherTemplate(String businessType, String businessId, VoucherTemplate voucherTemplate);

    @Modifying
    @Query(value = "delete from fin_business_document where post_date >= to_date(:startDate,'YYYY-MM-DD') and post_date <= to_date(:endDate,'YYYY-MM-DD') and voucher_template_id = :templateId ",nativeQuery = true)
    void deleteByPostdateAndVoucherTemplateId(String startDate,String endDate,String templateId);
}
